package com.vision.core.cl.ui.component;

import com.google.gwt.core.client.GWT;
import com.google.gwt.editor.client.Editor.Ignore;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiFactory;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Widget;
import com.sencha.gxt.widget.core.client.ContentPanel;
import com.sencha.gxt.widget.core.client.button.TextButton;
import com.sencha.gxt.widget.core.client.event.SelectEvent;
import com.sencha.gxt.widget.core.client.grid.Grid;
import com.sencha.gxt.widget.core.client.toolbar.ToolBar;

/**
 * 
 * @author Mark
 *
 */
public abstract class BasicGridWithButtonsPanel<T> extends ContentPanel {
	
	interface Binder extends UiBinder<Widget, BasicGridWithButtonsPanel<?>> { }

	private static final Binder binder = GWT.create(Binder.class);
	
	@Ignore @UiField
	protected ToolBar toolbar;
	
	@Ignore @UiField
	protected TextButton refreshBtn;
	
	@Ignore @UiField
	protected TextButton addBtn;
	
	@Ignore @UiField
	protected TextButton deleteBtn;
	
	@UiField
	protected Grid<T> grid;
	
	public BasicGridWithButtonsPanel() {
		super();
		
		setWidget(binder.createAndBindUi(this));
	}
	
	// UiFactory Methods %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	
	@UiFactory
	protected abstract Grid<T> createGrid();
	
	// UiHandler Methods %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	
	@UiHandler("refreshBtn")
	protected void refreshClicked(SelectEvent e) {
		
	}
	
	@UiHandler("addBtn")
	protected void adddClicked(SelectEvent e) {
		
	}
	
	@UiHandler("deleteBtn")
	protected void deleteClicked(SelectEvent e) {
		
	}
	
	// Getters %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
	
	public Grid<T> getGrid() {
		return grid;
	}

}
